<div class="BodyContainer">

<script type="text/javascript">
	var req;

	if (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
	} else {
		req = new ActiveXObject('Microsoft.XMLHTTP')
	}

	function doCallback(data)
	{
		var url = '%%GLOBAL_pathToKB%%/admin/index.php?ToDo=doDbBackup';
		if (!req) {
			return false;
		}

		document.body.style.cursor = 'wait';
		var bar = document.getElementById('progressbar');
		ToggleDisplay(bar);
		document.getElementById('start').style.display = 'none';
		document.getElementById('message').style.display = 'none';

		req.onreadystatechange = processReqChange;
		req.open('POST', url, true);
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.send(data);
	}

	function processReqChange() {
		if (req.readyState == 1) {
			document.getElementById('progresstext').innerHTML = '<br />Your knowledge base is being backed up. Please wait...<br /><br />';
		}
		// only if req shows 'loaded'
		if (req.readyState == 4) {
			// only if 'OK'
			if (req.status == 200) {
				BackupFinished(req.responseXML);
			} else {
				alert('There was a problem retrieving the XML data:\n' +
					req.responseText);
			}
			document.body.style.cursor = 'default';
			var bar = document.getElementById('progressbar');
			ToggleDisplay(bar);
		}
	}

	function BackupFinished(data)
	{
		var root = data.documentElement;
		if (root) {
			var percent = '';
			var feedback = '';
			for (j = 0; j < root.attributes.length; j++) {
				switch (root.attributes[j].nodeName) {
					case 'percent':
						percent = root.attributes[j].value;
						break;
					case 'feedback':
						feedback = root.attributes[j].value;
						break;
				}
			}

			document.location = '%%GLOBAL_pathToKB%%/admin/index.php?ToDo=backupDone&file=' + feedback;
		}
	}
	
	function StartBackup() {
		var inputs = document.getElementsByTagName('INPUT');
		var url = '';
		for(var i = 0; i < inputs.length; ++i) {
			if(inputs[i].type == "submit" || inputs[i].type == "button" || ((inputs[i].type == "checkbox" || inputs[i].type == "radio") && inputs[i].checked == false) || inputs[i].offsetHeight == 0)
				continue;
				url += '&'+inputs[i].name+'='+inputs[i].value;
		}
		tb_show('', 'index.php?ToDo=backupDatabaseInit'+url+'&keepThis=true&TB_iframe=tue&height=180&width=450&modal=true', '');
	}

</script>

<form method="post" onsubmit="return false" action="">
<table class="OuterPanel" cellspacing="0" cellpadding="0" border="0">
<tr>
	<td class="Heading1">%%LNG_BackupDatabase%%</td>
</tr>
<tr>
	<td>
		<table width="100%" border="0" cellpadding="0" cellspacing="0">
		<tr id="message">
			<td class="Intro" style="padding-top:8px;">
					%%LNG_BackupDatabaseIntro%%
			</td>
		</tr>
		<tr>
			<td>
				%%GLOBAL_Message%%
			</td>
		</tr>
		</table>
	</td>
</tr>
<tr>
	<td>
		<div style="display: %%GLOBAL_ShowBackupButton%%">
			<div id="progress">
				<div id="summary" style="margin-top:-5px">
					<br />
					<ul>
						<li>%%LNG_BackupNumberOfTables%% %%GLOBAL_NumTables%%</li>
						<li>%%LNG_BackupNumberOfRows%% %%GLOBAL_NumRows%%</li>
						<li>%%LNG_BackupMaxRows%% %%GLOBAL_MaxRows%% (%%GLOBAL_MaxRowTableName%%)</li>
						<li>%%LNG_BackupMinRows%% %%GLOBAL_MinRows%% (%%GLOBAL_MinRowTableName%%)</li>
					</ul>
				</div>
				<div id="start" style="margin-bottom: 20px">
					<input type="button" class="Field80" onclick="StartBackup(); return false;doCallback('start=0'); ToggleDisplay(document.getElementById('summary')); this.disabled=true;" value="Start Backup">
				</div>
				<div id="progresstext" class="text"></div>
				<div id="progressbar" style="display: none;"><img src="images/wait.gif" alt="wait"></div>
			</div>
		</div>
	</td>
</tr>
</table>
</form>

</div>